package org.yenn.pattern.aliyun.j2ee.Interceptingfilter;

import org.junit.Test;
import org.yenn.pattern.aliyun.j2ee.Interceptingfilter.impl.AuthenticationFilter;
import org.yenn.pattern.aliyun.j2ee.Interceptingfilter.impl.DebugFilter;

import static org.junit.Assert.*;

/**
 * @Author: yerenyun
 * @Description:步骤 7
 * 使用 Client 来演示拦截过滤器设计模式。
 */
public class InterceptingFilterPatternDemo {

    /**
     * 步骤 8
     * 验证输出。
     *
     * Authenticating request: HOME
     * request log: HOME
     * Executing request: HOME
     */
    @Test
    public void sendRequest() {
        FilterManager filterManager = new FilterManager(new Target());
        filterManager.setFilter(new AuthenticationFilter());
        filterManager.setFilter(new DebugFilter());

        Client client = new Client();
        client.setFilterManager(filterManager);
        client.sendRequest("HOME");
    }


}